First, we need to read the number of users (`U`) and operations (`N`). Then, we'll create our adjacency list.
Guidance for Step 1
- Adjacency List: For `U` users, we need a list containing `U` empty lists. `adj[i]` will store the friends for user `i`.
- Main Loop: We'll loop `N` times, reading and processing one command on each iteration.
- Your Task: Fill in the blank to correctly initialize the `adj` list. What syntax creates a new, empty list?
# Read U and N
U_str, N_str = input().strip().split()
U, N = int(U_str), int(N_str)
# Adjacency list: a list of U empty lists.
adj = [ _________ for _ in range(U)]
# Process N operations
for _ in range(N):
# Read the full command line
parts = input().strip().split()
# Get the operation name (e.g., "add", "degree")
op = parts[0]
if op == "add":
pass # To be implemented in Step 2
elif op == "degree":
pass # To be implemented in Step 3
elif op == "isfriend":
pass # To be implemented in Step 3
elif op == "count_greater":
pass # To be implemented in Step 4
Copied!